package com.jcrj.action.document;

import com.jcrj.action.BaseAction;
import com.jcrj.entity.OUser;
import com.jcrj.entity.OWorkflow;
import com.jcrj.service.FielTransactService;
import com.jcrj.service.TaskService;
import com.jcrj.service.WorkflowManagerService;
import com.jcrj.util.FielAll;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class FielTransactAction extends BaseAction
{
  private FielTransactService fielTransactService;
  private WorkflowManagerService workflowManagerService;
  private TaskService taskService;
  private List<FielAll> fielAll;
  private long totalCount;
  private long pageCount;
  private String name;
  private List<OWorkflow> flowList;

  public String guardFiel()
  {
    OUser user;
    try
    {
      user = (OUser)super.getSession().get("userInfo");
      String process = this.workflowManagerService.getSqlhis(user);
      this.fielAll = this.fielTransactService.getAllfiel(process, super.getCurrentPage(), this.name, null, super.getStartDate(), super.getEndDate());
      int i = 0; for (int sel = this.fielAll.size(); i < sel; ++i) {
        if (isNumeric(((FielAll)this.fielAll.get(i)).getSender())) {
          String count = ((FielAll)this.fielAll.get(i)).getSender();
          ((FielAll)this.fielAll.get(i)).setSender(this.taskService.getUserNameNew(Integer.parseInt(((FielAll)this.fielAll.get(i)).getSender())).getName());
          ((FielAll)this.fielAll.get(i)).setUnit(this.fielTransactService.getUserAllOrgName(this.taskService.getUserNameNew(Integer.parseInt(count)).getOrgId().intValue()));
        }
        if (isNumeric(((FielAll)this.fielAll.get(i)).getFlow())) {
          OWorkflow flow = this.fielTransactService.getWorkFlow(Integer.parseInt(((FielAll)this.fielAll.get(i)).getFlow()));
          if ((((FielAll)this.fielAll.get(i)).getTitle() == null) || ("".equals(((FielAll)this.fielAll.get(i)).getTitle())))
            ((FielAll)this.fielAll.get(i)).setTitle(flow.getName());

          ((FielAll)this.fielAll.get(i)).setFlow(flow.getTypeName());
        }
      }
      this.totalCount = this.fielTransactService.countAllFiel(process, this.name, null, super.getStartDate(), super.getEndDate()).longValue();
      this.pageCount = ((this.totalCount - 1L) / 10L + 1L);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "success";
  }

  public String waitFiel() {
    OUser user;
    try {
      user = (OUser)getSession().get("userInfo");
      List agent = this.taskService.getAgentUser(user);
      String process = this.workflowManagerService.getSqlProcessinstanceList(user.getId().intValue(), agent);
      this.fielAll = this.fielTransactService.getAllfiel(process, super.getCurrentPage(), this.name, null, super.getStartDate(), super.getEndDate());
      int i = 0; for (int sel = this.fielAll.size(); i < sel; ++i) {
        if (isNumeric(((FielAll)this.fielAll.get(i)).getSender())) {
          String count = ((FielAll)this.fielAll.get(i)).getSender();
          ((FielAll)this.fielAll.get(i)).setSender(this.taskService.getUserNameNew(Integer.parseInt(((FielAll)this.fielAll.get(i)).getSender())).getName());
          ((FielAll)this.fielAll.get(i)).setUnit(this.fielTransactService.getUserAllOrgName(this.taskService.getUserNameNew(Integer.parseInt(count)).getOrgId().intValue()));
        }
        if (isNumeric(((FielAll)this.fielAll.get(i)).getFlow())) {
          OWorkflow flow = this.fielTransactService.getWorkFlow(Integer.parseInt(((FielAll)this.fielAll.get(i)).getFlow()));
          if ((((FielAll)this.fielAll.get(i)).getTitle() == null) || ("".equals(((FielAll)this.fielAll.get(i)).getTitle())))
            ((FielAll)this.fielAll.get(i)).setTitle(flow.getName());

          ((FielAll)this.fielAll.get(i)).setFlow(flow.getTypeName());
        }
      }
      this.totalCount = this.fielTransactService.countAllFiel(process, this.name, null, super.getStartDate(), super.getEndDate()).longValue();
      this.pageCount = ((this.totalCount - 1L) / 10L + 1L);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "success";
  }

  public String waitWorkFlowTaskFile()
  {
    try {
      this.flowList = this.workflowManagerService.workFlowTypeList();
      OUser user = (OUser)getSession().get("userInfo");
      List agent = this.taskService.getAgentUser(user);
      String process = this.workflowManagerService.getSqlProcessinstanceList(user.getId().intValue(), agent);
      this.fielAll = this.fielTransactService.getWorkFlowTaskfile(process, super.getCurrentPage(), this.name, null, super.getStartDate(), super.getEndDate());
      int i = 0; for (int sel = this.fielAll.size(); i < sel; ++i) {
        if (isNumeric(((FielAll)this.fielAll.get(i)).getSender())) {
          String count = ((FielAll)this.fielAll.get(i)).getSender();
          ((FielAll)this.fielAll.get(i)).setSender(this.taskService.getUserNameNew(Integer.parseInt(((FielAll)this.fielAll.get(i)).getSender())).getName());
          ((FielAll)this.fielAll.get(i)).setUnit(this.fielTransactService.getUserAllOrgName(this.taskService.getUserNameNew(Integer.parseInt(count)).getOrgId().intValue()));
        }
        if (isNumeric(((FielAll)this.fielAll.get(i)).getFlow())) {
          OWorkflow flow = this.fielTransactService.getWorkFlow(Integer.parseInt(((FielAll)this.fielAll.get(i)).getFlow()));
          ((FielAll)this.fielAll.get(i)).setTitle(flow.getName());
          ((FielAll)this.fielAll.get(i)).setFlow(flow.getTypeName());
        }
      }
      this.totalCount = this.fielTransactService.countWorkFlowTaskFile(process, this.name, null, super.getStartDate(), super.getEndDate()).longValue();
      this.pageCount = ((this.totalCount - 1L) / 10L + 1L);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "success";
  }

  public String waitAllWorkFlowTaskFile()
  {
    try
    {
      this.flowList = this.workflowManagerService.workFlowTypeList();
      String process = this.workflowManagerService.getSqlAdminProcessList("task");
      this.fielAll = this.fielTransactService.getWorkFlowTaskfile(process, super.getCurrentPage(), this.name, null, super.getStartDate(), super.getEndDate());
      int i = 0; for (int sel = this.fielAll.size(); i < sel; ++i) {
        if (isNumeric(((FielAll)this.fielAll.get(i)).getSender())) {
          String count = ((FielAll)this.fielAll.get(i)).getSender();
          ((FielAll)this.fielAll.get(i)).setSender(this.taskService.getUserNameNew(Integer.parseInt(((FielAll)this.fielAll.get(i)).getSender())).getName());
          ((FielAll)this.fielAll.get(i)).setUnit(this.fielTransactService.getUserAllOrgName(this.taskService.getUserNameNew(Integer.parseInt(count)).getOrgId().intValue()));
        }
        if (isNumeric(((FielAll)this.fielAll.get(i)).getFlow())) {
          OWorkflow flow = this.fielTransactService.getWorkFlow(Integer.parseInt(((FielAll)this.fielAll.get(i)).getFlow()));
          ((FielAll)this.fielAll.get(i)).setTitle(flow.getName());
          ((FielAll)this.fielAll.get(i)).setFlow(flow.getTypeName());
        }
      }
      this.totalCount = this.fielTransactService.countWorkFlowTaskFile(process, this.name, null, super.getStartDate(), super.getEndDate()).longValue();
      this.pageCount = ((this.totalCount - 1L) / 10L + 1L);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "success";
  }

  public String overWorkFlowTaskFile()
  {
    try
    {
      this.flowList = this.workflowManagerService.workFlowTypeList();
      OUser user = (OUser)getSession().get("userInfo");
      String process = this.workflowManagerService.getSqlDoneProcessinstanceList(user.getId().intValue());
      this.fielAll = this.fielTransactService.getWorkFlowTaskfile(process, super.getCurrentPage(), this.name, null, super.getStartDate(), super.getEndDate());
      int i = 0; for (int sel = this.fielAll.size(); i < sel; ++i) {
        if (isNumeric(((FielAll)this.fielAll.get(i)).getSender())) {
          String count = ((FielAll)this.fielAll.get(i)).getSender();
          ((FielAll)this.fielAll.get(i)).setSender(this.taskService.getUserNameNew(Integer.parseInt(((FielAll)this.fielAll.get(i)).getSender())).getName());
          ((FielAll)this.fielAll.get(i)).setUnit(this.fielTransactService.getUserAllOrgName(this.taskService.getUserNameNew(Integer.parseInt(count)).getOrgId().intValue()));
        }
        if (isNumeric(((FielAll)this.fielAll.get(i)).getFlow())) {
          OWorkflow flow = this.fielTransactService.getWorkFlow(Integer.parseInt(((FielAll)this.fielAll.get(i)).getFlow()));
          ((FielAll)this.fielAll.get(i)).setTitle(flow.getName());
          ((FielAll)this.fielAll.get(i)).setFlow(flow.getTypeName());
        }
      }
      this.totalCount = this.fielTransactService.countWorkFlowTaskFile(process, this.name, null, super.getStartDate(), super.getEndDate()).longValue();
      this.pageCount = ((this.totalCount - 1L) / 10L + 1L);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "success";
  }

  public String overAllWorkFlowTaskFile()
  {
    try
    {
      this.flowList = this.workflowManagerService.workFlowTypeList();
      String process = this.workflowManagerService.getSqlAdminProcessList("end");
      this.fielAll = this.fielTransactService.getWorkFlowTaskfile(process, super.getCurrentPage(), this.name, null, super.getStartDate(), super.getEndDate());
      int i = 0; for (int sel = this.fielAll.size(); i < sel; ++i) {
        if (isNumeric(((FielAll)this.fielAll.get(i)).getSender())) {
          String count = ((FielAll)this.fielAll.get(i)).getSender();
          ((FielAll)this.fielAll.get(i)).setSender(this.taskService.getUserNameNew(Integer.parseInt(((FielAll)this.fielAll.get(i)).getSender())).getName());
          ((FielAll)this.fielAll.get(i)).setUnit(this.fielTransactService.getUserAllOrgName(this.taskService.getUserNameNew(Integer.parseInt(count)).getOrgId().intValue()));
        }
        if (isNumeric(((FielAll)this.fielAll.get(i)).getFlow())) {
          OWorkflow flow = this.fielTransactService.getWorkFlow(Integer.parseInt(((FielAll)this.fielAll.get(i)).getFlow()));
          ((FielAll)this.fielAll.get(i)).setTitle(flow.getName());
          ((FielAll)this.fielAll.get(i)).setFlow(flow.getTypeName());
        }
      }
      this.totalCount = this.fielTransactService.countWorkFlowTaskFile(process, this.name, null, super.getStartDate(), super.getEndDate()).longValue();
      this.pageCount = ((this.totalCount - 1L) / 10L + 1L);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "success";
  }

  public String rejectWorkFlowTaskFile()
  {
    try
    {
      this.flowList = this.workflowManagerService.workFlowTypeList();
      OUser user = (OUser)getSession().get("userInfo");
      List agent = this.taskService.getAgentUser(user);
      String process = this.workflowManagerService.getSqlProcessinstanceList(user.getId().intValue(), agent);
      this.fielAll = this.fielTransactService.getWorkFlowTaskfile(process, super.getCurrentPage(), this.name, user, super.getStartDate(), super.getEndDate());
      int i = 0; for (int sel = this.fielAll.size(); i < sel; ++i) {
        if (isNumeric(((FielAll)this.fielAll.get(i)).getSender())) {
          String count = ((FielAll)this.fielAll.get(i)).getSender();
          ((FielAll)this.fielAll.get(i)).setSender(this.taskService.getUserNameNew(Integer.parseInt(((FielAll)this.fielAll.get(i)).getSender())).getName());
          ((FielAll)this.fielAll.get(i)).setUnit(this.fielTransactService.getUserAllOrgName(this.taskService.getUserNameNew(Integer.parseInt(count)).getOrgId().intValue()));
        }
        if (isNumeric(((FielAll)this.fielAll.get(i)).getFlow())) {
          OWorkflow flow = this.fielTransactService.getWorkFlow(Integer.parseInt(((FielAll)this.fielAll.get(i)).getFlow()));
          ((FielAll)this.fielAll.get(i)).setTitle(flow.getName());
          ((FielAll)this.fielAll.get(i)).setFlow(flow.getTypeName());
        }
      }
      this.totalCount = this.fielTransactService.countWorkFlowTaskFile(process, this.name, user, super.getStartDate(), super.getEndDate()).longValue();
      this.pageCount = ((this.totalCount - 1L) / 10L + 1L);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "success";
  }

  public String hasWaitFiel()
  {
    OUser user;
    try {
      user = (OUser)getSession().get("userInfo");
      String process = this.workflowManagerService.getSqlDoneProcessinstanceList(user.getId().intValue());
      this.fielAll = this.fielTransactService.getAllfiel(process, super.getCurrentPage(), this.name, null, super.getStartDate(), super.getEndDate());
      int i = 0; for (int sel = this.fielAll.size(); i < sel; ++i) {
        if (isNumeric(((FielAll)this.fielAll.get(i)).getSender())) {
          String count = ((FielAll)this.fielAll.get(i)).getSender();
          ((FielAll)this.fielAll.get(i)).setSender(this.taskService.getUserNameNew(Integer.parseInt(((FielAll)this.fielAll.get(i)).getSender())).getName());
          ((FielAll)this.fielAll.get(i)).setUnit(this.fielTransactService.getUserAllOrgName(this.taskService.getUserNameNew(Integer.parseInt(count)).getOrgId().intValue()));
        }
        if (isNumeric(((FielAll)this.fielAll.get(i)).getFlow())) {
          OWorkflow flow = this.fielTransactService.getWorkFlow(Integer.parseInt(((FielAll)this.fielAll.get(i)).getFlow()));
          if ((((FielAll)this.fielAll.get(i)).getTitle() == null) || ("".equals(((FielAll)this.fielAll.get(i)).getTitle())))
            ((FielAll)this.fielAll.get(i)).setTitle(flow.getName());

          ((FielAll)this.fielAll.get(i)).setFlow(flow.getTypeName());
        }
      }
      this.totalCount = this.fielTransactService.countAllFiel(process, this.name, null, super.getStartDate(), super.getEndDate()).longValue();
      this.pageCount = ((this.totalCount - 1L) / 10L + 1L);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "success"; }

  public String endFiel() {
    OUser user;
    try {
      user = (OUser)getSession().get("userInfo");
      String process = this.workflowManagerService.getSqlDoneProcessinstanceList(user.getId().intValue());
      this.fielAll = this.fielTransactService.getAllfiel(process, super.getCurrentPage(), this.name, null, super.getStartDate(), super.getEndDate());
      int i = 0; for (int sel = this.fielAll.size(); i < sel; ++i) {
        if (isNumeric(((FielAll)this.fielAll.get(i)).getSender())) {
          String count = ((FielAll)this.fielAll.get(i)).getSender();
          ((FielAll)this.fielAll.get(i)).setSender(this.taskService.getUserNameNew(Integer.parseInt(((FielAll)this.fielAll.get(i)).getSender())).getName());
          ((FielAll)this.fielAll.get(i)).setUnit(this.fielTransactService.getUserAllOrgName(this.taskService.getUserNameNew(Integer.parseInt(count)).getOrgId().intValue()));
        }
        if (isNumeric(((FielAll)this.fielAll.get(i)).getFlow())) {
          OWorkflow flow = this.fielTransactService.getWorkFlow(Integer.parseInt(((FielAll)this.fielAll.get(i)).getFlow()));
          if ((((FielAll)this.fielAll.get(i)).getTitle() == null) || ("".equals(((FielAll)this.fielAll.get(i)).getTitle())))
            ((FielAll)this.fielAll.get(i)).setTitle(flow.getName());

          ((FielAll)this.fielAll.get(i)).setFlow(flow.getTypeName());
        }
      }
      this.totalCount = this.fielTransactService.countAllFiel(process, this.name, null, super.getStartDate(), super.getEndDate()).longValue();
      this.pageCount = ((this.totalCount - 1L) / 10L + 1L);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "success";
  }

  public String rejectFiel() {
    OUser user;
    try {
      user = (OUser)getSession().get("userInfo");
      List agent = this.taskService.getAgentUser(user);
      String process = this.workflowManagerService.getSqlProcessinstanceList(user.getId().intValue(), agent);
      this.fielAll = this.fielTransactService.getAllfiel(process, super.getCurrentPage(), this.name, user, super.getStartDate(), super.getEndDate());
      int i = 0; for (int sel = this.fielAll.size(); i < sel; ++i) {
        if (isNumeric(((FielAll)this.fielAll.get(i)).getSender())) {
          String count = ((FielAll)this.fielAll.get(i)).getSender();
          ((FielAll)this.fielAll.get(i)).setSender(this.taskService.getUserNameNew(Integer.parseInt(((FielAll)this.fielAll.get(i)).getSender())).getName());
          ((FielAll)this.fielAll.get(i)).setUnit(this.fielTransactService.getUserAllOrgName(this.taskService.getUserNameNew(Integer.parseInt(count)).getOrgId().intValue()));
        }
        if (isNumeric(((FielAll)this.fielAll.get(i)).getFlow())) {
          OWorkflow flow = this.fielTransactService.getWorkFlow(Integer.parseInt(((FielAll)this.fielAll.get(i)).getFlow()));
          if ((((FielAll)this.fielAll.get(i)).getTitle() == null) || ("".equals(((FielAll)this.fielAll.get(i)).getTitle())))
            ((FielAll)this.fielAll.get(i)).setTitle(flow.getName());

          ((FielAll)this.fielAll.get(i)).setFlow(flow.getTypeName());
        }
      }
      this.totalCount = this.fielTransactService.countAllFiel(process, this.name, user, super.getStartDate(), super.getEndDate()).longValue();
      this.pageCount = ((this.totalCount - 1L) / 10L + 1L);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "success";
  }

  public boolean isNumeric(String str)
  {
    Pattern pattern = Pattern.compile("[0-9]*");
    Matcher isNum = pattern.matcher(str);

    return (isNum.matches());
  }

  public FielTransactService getFielTransactService()
  {
    return this.fielTransactService;
  }

  public void setFielTransactService(FielTransactService fielTransactService) {
    this.fielTransactService = fielTransactService;
  }

  public WorkflowManagerService getWorkflowManagerService() {
    return this.workflowManagerService;
  }

  public void setWorkflowManagerService(WorkflowManagerService workflowManagerService)
  {
    this.workflowManagerService = workflowManagerService;
  }

  public List<FielAll> getFielAll() {
    return this.fielAll;
  }

  public void setFielAll(List<FielAll> fielAll) {
    fielAll = fielAll;
  }

  public long getTotalCount() {
    return this.totalCount;
  }

  public void setTotalCount(long totalCount) {
    this.totalCount = totalCount;
  }

  public long getPageCount() {
    return this.pageCount;
  }

  public void setPageCount(long pageCount) {
    this.pageCount = pageCount;
  }

  public String getName() {
    return this.name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public TaskService getTaskService() {
    return this.taskService;
  }

  public void setTaskService(TaskService taskService) {
    this.taskService = taskService;
  }

  public List<OWorkflow> getFlowList() {
    return this.flowList;
  }

  public void setFlowList(List<OWorkflow> flowList) {
    this.flowList = flowList;
  }
}